package org.linlinjava.litemall.db.service;

import org.apache.ibatis.annotations.Param;
import org.linlinjava.litemall.db.dao.AgedmallRfidGoodsProductMapper;
import org.linlinjava.litemall.db.dao.app.AppRfidGoodsProductMapper;
import org.linlinjava.litemall.db.domain.AgedmallCabinetGoods;
import org.linlinjava.litemall.db.domain.AgedmallRfidGoodsProduct;
import org.linlinjava.litemall.db.domain.AgedmallRfidGoodsProductExample;
import org.linlinjava.litemall.db.vo.app.InStockStoreGoodsDto;
import org.linlinjava.litemall.db.vo.app.InStockStoreOrderDto;
import org.linlinjava.litemall.db.vo.app.RfidGoodsVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AgedmallRfidGoodsProductService {

    @Resource
    private AgedmallRfidGoodsProductMapper agedmallRfidGoodsProductMapper;
    @Resource
    private AppRfidGoodsProductMapper appRfidGoodsProductMapper;

    public List<RfidGoodsVo> storeGoodsByRfidList(List<String> rfidList) {
        return appRfidGoodsProductMapper.storeGoodsByRfidList(rfidList);
    }

    public RfidGoodsVo storeGoodsByRfid(String rfid) {
        return appRfidGoodsProductMapper.storeGoodsByRfid(rfid);
    }

    public List<RfidGoodsVo> storeGoodsByStoreId(String storeId) {
        return appRfidGoodsProductMapper.storeGoodsByStoreId(storeId);
    }

    public AgedmallRfidGoodsProduct findByRfid(String rfid) {
        AgedmallRfidGoodsProductExample example = new AgedmallRfidGoodsProductExample();
        example.createCriteria().andDeletedEqualTo(false)
                .andRfidEqualTo(rfid);
        return agedmallRfidGoodsProductMapper.selectOneByExample(example);
    }

    public AgedmallRfidGoodsProduct findByRfidAndStoreId(String rfid, Integer storeId) {
        AgedmallRfidGoodsProductExample example = new AgedmallRfidGoodsProductExample();
        example.createCriteria().andDeletedEqualTo(false)
                .andStoreIdEqualTo(storeId.longValue())
                .andRfidEqualTo(rfid);
        return agedmallRfidGoodsProductMapper.selectOneByExample(example);
    }

    public void updateRfid(String storeId, String oldRfid, String newRfid) {
        appRfidGoodsProductMapper.updateRfid(storeId, oldRfid, newRfid);
    }

    public List<InStockStoreGoodsDto> selectGoodsMessageByInStockStoreGoods(List<String> rfidList) {
        return appRfidGoodsProductMapper.selectGoodsMessageByInStockStoreGoods(rfidList);
    }

    public List<InStockStoreOrderDto> selectOrderMessageByInStockStoreGoods(List<Long> rfidList) {
        return appRfidGoodsProductMapper.selectOrderMessageByInStockStoreGoods(rfidList);
    }

    public Long selectCabinetIdByRfid(String rfid) {
        return appRfidGoodsProductMapper.selectCabinetIdByRfid(rfid);
    }

    public int insertCabinetGoodsBatch(List<AgedmallCabinetGoods> list){
        return appRfidGoodsProductMapper.insertCabinetGoodsBatch(list);
    }
}
